Need applescript for Messages to send Passbook .pkpass attachments

Hi - I'm trying to write an applescript to send iMessages to a list of recipient Phone numbers with Passbook .pkpass files as attachments.


Here's my simple sendMessage.applescript file


on run {targetBuddyPhone, targetMessage, targetFile}

tell application "Messages"

set targetService to 1st service whose service type = iMessage

set targetBuddy to buddytargetBuddyPhone of targetService


sendtargetMessagetotargetBuddy


sendfiletargetFiletotargetBuddy

end tell

end run


I'm calling this from Terminal with command:


osascript sendMessage.applescript <Phonenumber> "Here's your Passbook coupon" Coupon.pkpass


When I execute the command, my targetMessage is correctly sent. However, the .pkpass file transfer says it is waiting for the recipient to accept the file transfer.

When I send it to my own iPhone, I don't receive any request to accept a file transfer.


How can I modify this script such that the file is properly attached to the iMessage and it sends with an auto-accept condition ?


Thanks if you can help,

Andrew

Mac mini, OS X Mountain Lion (10.8.3)

Posted on Nov 2, 2013 2:58 PM

Reply
1 reply

Jun 4, 2016 5:11 AM in response to andrewlausanne

This should help with the targetfile you are trying to send.

set targetfile to POSIX file "/Users/Andrew/Desktop/EnergyUse.pdf"

send targetFile to targetBuddy

Don't need the word "file" in the send script. "send file targetFile to targetBuddy"

Obviously set it to the path of your file. I'm showing an example of a PDF. When i was trying to find an example of attaching a file / picture some of the examples were incorrect.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Need applescript for Messages to send Passbook .pkpass attachments

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.